<style>
    #deliveryAddress .input-div input{height: auto;}
   select{-webkit-appearance:none;}
    .dizhi{color:#000000 !important;}
    input{font-size: 1.3rem !important;}
    .dizhi{font-size: 1.3rem; margin-left: 30px;}
</style>
<div id="deliveryAddress">
    <div class="heading">
        <a href="#"><img src="resource/images/img-17-8.jpg" /></a>
       填写个人信息
    </div>



<form id="express_form" action="">
    <div id="express" class="receiver"  >
        <div>
            <label>收货人 <span>*</span></label>
            <div class="input-div">
                <input type="text" name="cnee_name" />
            </div>
        </div>
        <div>
            <label>手&nbsp;&nbsp;&nbsp;&nbsp;机 <span>*</span></label>
            <div class="input-div">
                <input type="text" name="phone" />
            </div>
        </div>
        <div class="option-select">
            <label>省&nbsp;&nbsp;&nbsp;&nbsp;份 <span>*</span></label>
            <span name="sheng_span" class="sheng_span dizhi" ></span>
            <div class="select-div" >
                <select name="sheng" id="sheng" >
                    <option value="">请选择省份..</option>
                    <?php foreach($output['area_list'] as $k =>$v){ ?>
                        <option value="<?php echo $v['area_id']; ?>"><?php echo $v['name']?></option>
                    <?php  } ?>
               </select>
             </div>
            <a href="#"> > </a>
        </div>
        <div class="option-select">
            <label>城&nbsp;&nbsp;&nbsp;&nbsp;市 <span>*</span></label>
            <span name="shi_span" class="shi_span dizhi"></span>
            <div class="select-div">
                <select name="shi" id="shi" >
                  <option value="">请选择市区..</option>
                </select>
            </div>
            <a href="#"> > </a>
        </div>
        <div class="option-select">
            <label>区&nbsp;&nbsp;&nbsp;&nbsp;县 <span>*</span></label>
            <span name="qu_span" class="qu_span dizhi"></span>
            <div class="select-div">
                <select name="qu" id="qu">
                    <option value="">请选择区县..</option>
                </select>
            </div>
            <a href="#"> > </a>
        </div>
        <div class="xiangxi">
            <label>详细地址 <span>*</span></label>
            <div class="input-div">
                <input type="text"  name="address_name" />
            </div>
        </div>
        <div class="youbian">
            <label>邮&nbsp;&nbsp;&nbsp;&nbsp;编 </label>
            <div class="input-div">
                <input type="text" name="postcode" />
            </div>
        </div>
    </div>
    <input type="hidden" name="bargain_id" value="<?php echo $output['order_info']['bargain_id'] ?>">
    <input type="hidden" name="order_id"   value="<?php echo $output['order_id'];?>">
    <input type="hidden" name="type" value="<?php echo $output['order_info']['type']; ?>">
    <input type="hidden" name="form_submit" value="ok" >
    <input type="hidden" name="minute_address" value="">
</form>
    <div class="btn" style="margin: 5% auto;">确定</div>

</div>
<script>
    <?php if($output['type']==1){ ?>
      $(".option-select").hide();
      $(".xiangxi").hide();
      $(".youbian").hide();
    <?php  }?>
$(function(){

    //地址
    $("#sheng").change(function(){
        var area_id = $("#sheng").val();
        var span_text = $("#sheng").find("option:selected").text()
        $("[name='sheng_span']").empty();
        $("[name='sheng_span']").text(span_text);
        $("[name='shi_span']").empty();
        $("[name='shi_span']").text('请选择城市..');
        $("[name='qu_span']").empty();
        $("[name='qu_span']").text('请选择区县..');
        $.ajax({
            type:'post',
            url:'index.php?act=bargain_order&op=area_list',
            data:{area_id:area_id},
            dataType:'json',
            success:function(result){
              //alert(result.datas.area_list);
                $obj = $("#shi");
                $obj.empty();
                $("#shi").empty();
                $("#qu").empty();
                var data = result.datas;
                $obj.append('<option value="">请选择城市...</option>')
                for (var i=0; i<data.area_list.length; i++){
                    $obj.append('<option value="'+data.area_list[i].area_id+'">'+ data.area_list[i].name +'</option>');
                }
            }


        })
    });
    $("#shi").change(function(){
        var area_id = $("#shi").val();
        var span_text = $("#shi").find("option:selected").text()
        $("[name='shi_span']").empty();
        $("[name='shi_span']").text(span_text);
        $("[name='qu_span']").empty();
        $("[name='qu_span']").text('请选择区县..');
        $.ajax({
            type:'post',
            url:'index.php?act=bargain_order&op=area_list',
            data:{area_id:area_id},
            dataType:'json',
            success:function(result){
                //alert(result.datas.area_list);
                $obj = $("#qu");
                $obj.empty();
                $("#qu").empty();
                var data = result.datas;
                $obj.append('<option value="">请选择区县...</option>')
                for (var i=0; i<data.area_list.length; i++){
                    $obj.append('<option value="'+data.area_list[i].area_id+'">'+ data.area_list[i].name +'</option>');
                }
            }


        })
    });
    $("#qu").change(function(){
        var span_text = $("#qu").find("option:selected").text()

        $("[name='qu_span']").empty();
        $("[name='qu_span']").text(span_text);

    })

})
</script>
<script>

    $(function(){
        var is_weixin = '<?php echo $output['is_weixin'] ?>' ;
        $(".btn").click(function(){
            var cnee_name = $("[name='cnee_name']").val();
            var phone = $("[name='phone']").val();
            if(cnee_name ==''){
                popAlert('收货人姓名不能为空噢！');
                return;
            }
            if(!(/^1\d{10}$/.test(phone))){
                popAlert('手机号码格式不正确！');
                return;
            }
            <?php if($output['type']==0) {?>

            var qu_id = $("[name='qu']").val();
            var address_name = $("[name='address_name']").val();
            var sheng_text = $("#sheng").find("option:selected").text();
            var shi_text   = $("#shi").find("option:selected").text();
            var qu_text    = $("#qu").find("option:selected").text();
            $("[name='minute_address']").val(sheng_text+shi_text+qu_text+address_name);
            if(qu_id ==''){
               popAlert('地址请选到区县噢！');
                return;
            }
            if(address_name ==''){
                popAlert('详细地址不能为空噢！');
                return;
            }
            <?php  }   ?>
            $.post(location.href,$("#express_form").serialize(),function(result){

              try {
                  typeof(result.datas.error) ==='string' &&  popAlert(result.datas.error);
                  typeof(result.datas) ==='string' &&  popAlert(result.datas,tiaozhuan());
               }catch (e){
                   if(is_weixin ==''){
                        window.location.href = result.data.code_url;
                    }else{
                        $('html').append(result.data.html);
                    }
                }
                /*alert(result.datas.error);*/
              /*if(result.datas.error !=''){
                  popAlert(result.datas.error);
              }else{
                  //提交成功,跳去支付
                  /!*if(is_weixin ==''){
                     window.location.href = result.data.code_url;
                  }else{
                      $('html').append(result.data.html);
                  }*!/
              }*/
            },'json');

        });
    })
function tiaozhuan(){
    window.location.href="index.php?act=bargain_order";
}
</script>